﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using org.project.web.utils;
using System.Data;
using System.Configuration;
public partial class signup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) {
    }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        String MAccount = MAccountTextBox.Text;
        String MPassword = MPasswordTextBox.Text;
        String MNowLiveIn = MNowLiveInTextBox.Text;
        String MName = MNameTextBox.Text;
        String MTel = MTelTextBox.Text;
        String MWork = MWorkTextBox.Text;
        String MCompany = MCompanyTextBox.Text;
        String preInsertSql = "Select MAccount from Member Where MAccount ='" + MAccount + "'";
        
        String sql = "INSERT INTO Member(MAccount,MPassword,MNowLiveIn,MName,MTel,MWork,MCompany) values ('" + MAccount + "','" + MPassword + "','" + MNowLiveIn + "','" + MName + "','" + MTel + "','" + MWork + "','" + MCompany + "')";

        //INSERT INTO [EIP].[dbo].[sys_docs_modify] ([欄位1]" +",[欄位2]) VALUES ('插入資料1','插入資料2')

        SQLUtility uility = new SQLUtility();
        DataSet dataSet = new DataSet();

        int rows = uility.ExecuteCommandRows(ConfigurationManager.ConnectionStrings["projectConnectionString"].ConnectionString, preInsertSql);

        if (rows >= 1)
        {
            Response.Write("<script >alert('此帳號已經存在..！');</script>");
        }
        else
        {
            uility.ExecuteCommand(ConfigurationManager.ConnectionStrings["projectConnectionString"].ConnectionString, sql);
        }

    }
}